<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
    <head><link rel="stylesheet" type="text/css" href="description/Combined.css,0:HeaderFooterSprite,0:Header.NonMtps,1:LinkList;/Areas/Centers/Themes/StandardDevCenter/Content:0,/Areas/Epx/Themes/Base/Content:1&amp;amp;hashKey=C9973DA951AE6202C9B348379A1BE49D" xmlns="http://www.w3.org/1999/xhtml" />
<link type="text/css" rel="stylesheet" xmlns="http://www.w3.org/1999/xhtml" />
<link rel="stylesheet" type="text/css" href="description/9bf1b74c-1640-46af-84d3-e440c8f95162Combined.css,0:HeaderFooterSprite,0:Footer.NonMtps,1:LinkList;/Areas/Centers/Themes/StandardDevCenter/Content:0,/Areas/Epx/Themes/Base/Content:1&amp;amp;hashKey=F576C687BC536B84D6E5B3246EE39B49" xmlns="http://www.w3.org/1999/xhtml" />
<link type="text/css" rel="stylesheet" xmlns="http://www.w3.org/1999/xhtml" />

        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
        <title>SharePoint 2013: MyFileConnector custom BCS indexing connector sample</title>
        <link href="description/Galleries.css" type="text/css" rel="Stylesheet" /><link href="description/Layout.css" type="text/css" rel="Stylesheet" /><link href="description/Brand.css" type="text/css" rel="Stylesheet" />
        <link href="description/iframedescription.css" rel="Stylesheet" type="text/css" />
        <script src="description/offline.js" type="text/javascript"></script>
        <style type="text/css">
            #projectInfo {
                overflow: auto;
            }
            #longDesc {
                clear:both;
                margin: 25px 0 10px 0;
            }

            #SampleIndexList{
                margin-left: 15px;
            }
        </style>
    </head>
<body>
    <div id="offlineDescription">
        <h1>SharePoint 2013: MyFileConnector custom BCS indexing connector sample</h1>
        <br/>
        <div id="projectInfo">
            <div class="section">
                    <div class="itemBarLong tagsContainer">
                        <label for="Technologies">Technologies</label>
                        <div id="Technologies">
                            C#, SharePoint Server 2013, SharePoint Foundation 2013, apps for SharePoint
                        </div>
                    </div>
                    <div class="itemBarLong tagsContainer">
                        <label for="Topics">Topics</label>
                        <div id="Topics">
                            Search, data and storage
                        </div>
                    </div>
                <div class="itemBarLong">
                    <label for="Platforms">Platforms</label>
                    <div id="Platforms">
                        Web, Cloud
                    </div>
                </div>
                <div class="itemBarLong">
                    <label for="Requirements">Requirements</label>
                    <div id="Requirements">
                        
                    </div>
                </div>
                <div class="itemBar">
                    <label for="LastUpdated">Primary language</label>
                    <div id="LastUpdated">en-US</div>
                </div>
                <div class="itemBar">
                    <label for="LastUpdated">Updated</label>
                    <div id="LastUpdated">3/19/2013</div>
                </div>
                <div class="itemBarLong">
                    <label for="License">License</label>
                    <div id="License">
                        <a href="license.rtf">Apache License, Version 2.0</a></div>
                </div>
                <div class="itemBar">
                    <div class="viewonlinecont">
                        <a data-link="online" href="http://code.msdn.microsoft.com/SharePoint-2013-MyFileConne-79d2ea26">View this sample online</a>
                    </div>
                </div>
            </div>
        </div>
        
                   
<script type="text/javascript">
    function initializePage() {
        var otherTabClass = 'otherTab';
        var hiddenPreClass = 'hidden';

        var htmlDecode = function(encodedData) {
            var decodedData = "";
            if (encodedData) {
                var div = document.createElement('div');
                div.innerHTML = encodedData;
                decodedData = div.firstChild.nodeValue.replace( /\\r\\n/ig , '\r\n');
            }
            return decodedData;
        };
                
        Galleries.iterateElem(Galleries.findElem(null, 'div', 'scriptcode'), function (index, scriptBlock) {
            var titleElem = Galleries.findElem(scriptBlock, 'div', 'title')[0];
            var labelElems = Galleries.findElem(titleElem, 'span');
            if (labelElems.length == 0) {
                labelElems = titleElem;
            }
            var languageSpans = Galleries.findElem(scriptBlock, 'span', 'hidden');
            var pres = Galleries.findElem(scriptBlock, 'pre');
            if (languageSpans.length > 0 && pres.length > 1) {
                Galleries.iterateElem(labelElems, function(index, elem) {
                    var codePre = pres[index];
                    var labelSpan = elem;
                    var languageSpan = languageSpans[index];
                            
                    elem.code = codePre.innerHTML.replace( /(\r(\n)?)|((\r)?\n)/ig , '\\r\\n');
                            
                    codePre.className = codePre.className.replace(hiddenPreClass, '');
                            
                    languageSpan.parentNode.removeChild(languageSpan);
                });

                pres = Galleries.findElem(scriptBlock, 'pre');
                Galleries.iterateElem(labelElems, function(index, elem) {
                    var codePre = pres[index];
                    var labelSpan = elem;
                    if (index == 0) {
                        scriptBlock.activeTab = 0;
                    }
                    else {
                        labelSpan.className += otherTabClass;
                        codePre.className += hiddenPreClass;
                    }
                    Galleries.attachEventHandler(labelSpan, 'click', function(e) {
                        var activeTab = scriptBlock.activeTab;
                        labelElems[activeTab].className += otherTabClass;
                        pres[activeTab].className += hiddenPreClass;

                        codePre.className = codePre.className.replace(hiddenPreClass, '');
                        labelSpan.className = labelSpan.className.replace(otherTabClass, '');
                        scriptBlock.activeTab = index;
                    });
                });

                var preview = Galleries.findElem(scriptBlock, 'div', 'preview');
                if (preview.length == 0) {
                    preview.push(pres[pres.length - 1]);
                }
                Galleries.iterateElem(preview, function(index, elem) {
                    elem.parentNode.removeChild(elem);
                });

                if (window.clipboardData && clipboardData.setData) {
                    var copyLink = document.createElement('a');
                    copyLink.href = 'javascript:void(0);';
                    copyLink.className = 'copyCode';
                    copyLink.innerHTML = 'Copy code';
                    Galleries.attachEventHandler(copyLink, 'click', function (e) {
                        clipboardData.setData("Text", htmlDecode(labelElems[scriptBlock.activeTab].code));
                        return false;
                    });
                    scriptBlock.insertBefore(copyLink, scriptBlock.childNodes[0]);
                }
            }
        });
    }

    Galleries.onWindowLoad(function(){
        initializePage();
    });

</script>
<div id="longDesc">
    
<p><span style="font-size:small">The MyFileConnector sample demonstrates how to create a basic &#65279;Business Connectivity Services (BCS) indexing connector that crawls all files and folders within a file share on a Windows file system. This sample is designed to
 show you how to create custom BCS indexing connectors. For more information about creating custom indexing connectors, see
<a href="http://msdn.microsoft.com/library/38560a3b-69c6-4a56-97ca-3625bbd5755e.aspx">
Search connector framework in SharePoint 2013</a>.</span></p>
<h1>Prerequisites</h1>
<p><span style="font-size:small">This sample requires the following:</span></p>
<ul>
<li><span style="font-size:small">Visual Studio</span> </li><li><span style="font-size:small">SharePoint Server 2013</span> </li></ul>
<h1><span style="font-size:medium">Key components of the MyFileConnector sample</span></h1>
<p><span style="font-size:small">The MyFileConnector sample contains the following:</span></p>
<ul>
<li><span style="font-size:small">MyFile.cs, which defines the file and folder external content types, and provides the method implementations for the
<strong>Finder</strong> and <strong>SpecificFinder</strong> operations</span> </li><li><span style="font-size:small">MyFileConnector.cs, which derives from the <strong>
StructuredRepositorySystemUtility</strong> class, which implements the <a href="http://msdn.microsoft.com/library/Microsoft.BusinessData.Runtime.ISystemUtility">
ISystemUtility</a>&nbsp;interface.</span> </li><li><span style="font-size:small">MyFileLobUri.cs, which derives from the <a href="http://msdn.microsoft.com/library/Microsoft.Office.Server.Search.Connector.BDC.LobUri">
LobUri</a> class, which maps the URLs as they are passed from Search to BCS. </span>
</li><li><span style="font-size:small">MyFileNamingContainer.cs, which implements the <a href="http://msdn.microsoft.com/library/Microsoft.Office.Server.Search.Connector.BDC.INamingContainer">
INamingContainer</a> interface, and maps the URLs as they are passed from BCS to Search.</span>
</li><li><span style="font-size:small">MyFileModel.xml, which is the BDC model file for the MyFileConnector sample.</span>
</li></ul>
<h1>Configure the sample</h1>
<ol>
<li><span style="font-size:small">Open the MyFileConnector project in Visual Studio.</span>
</li><li><span style="font-size:small">In <strong>Solution Explorer</strong>, expand the
<strong>References</strong> folder, and then restore any missing project references.&nbsp; The sample includes references to the following SharePoint Server 2013 assemblies:</span>
</li></ol>
<p style="padding-left:60px"><span style="font-size:small">&bull;&nbsp;<strong>Microsoft.BusinessData</strong></span><br>
<span style="font-size:small">&bull;&nbsp;<strong><a class="libraryLink" href="http://msdn.microsoft.com/en-US/library/Microsoft.SharePoint.aspx"  title="Auto generated link to Microsoft.SharePoint">Microsoft.SharePoint</a></strong></span><br>
<span style="font-size:small">&bull;&nbsp;<strong>Microsoft.Office.Server.Search.Connector</strong></span></p>
<h1>Run and test the sample</h1>
<p><span style="font-size:small">To deploy the MyFileConnector sample:</span></p>
<ol>
<li><span style="font-size:small">On the application server, add the sample assembly (MyFileConnector.dll) to the global assembly cache. For more information, see
<a href="http://msdn.microsoft.com/en-us/library/dkkx7f79(v=VS.110).aspx" >
How to: Install an Assembly into the Global Assembly Cache</a>.</span> </li><li><span style="font-size:small">Copy MyFileModel.xml to the application server.</span>
</li><li><span style="font-size:small">Open the SharePoint Management Shell. </span></li><li><span style="font-size:small">At the command prompt, do the following:<br>
</span><br>
<span style="font-size:small">&bull;&nbsp;Type the following command, and then run it.</span><br>
<span style="font-size:small"><br>
&nbsp;&nbsp;<strong>$searchapp = Get-SPEnterpriseSearchServiceApplication</strong></span><br>
<span style="font-size:small"><br>
&bull;&nbsp;Type the following command, and then run it.</span><br>
<span style="font-size:small"><br>
&nbsp;&nbsp;<strong>New-SPEnterpriseSearchCrawlCustomConnector -SearchApplication $searchapp -protocol myfile -ModelFilePath &quot;<a href="http://code.msdn.microsoft.com/SharePoint-2013-MyFileConne-79d2ea26/file://\\ServerName\FolderName\MyFileModel.xml">\\ServerName\FolderName\MyFileModel.xml</a>&quot; -Name myfile</strong></span>
</li><li><span style="font-size:small">Add the following registry subkey to the server, and then set the value to
<strong>OSearch15.ConnectorProtocolHandler.1</strong>:</span><br>
<span style="font-size:small">[HKEY_LOCAL_MACHINE]\ SOFTWARE\Microsoft\Office Server\15.0\Search\Setup\ProtocolHandlers\myfile</span>
</li><li><span style="font-size:small">At the command prompt, do the following:</span><br>
<span style="font-size:small">&bull; Type the following command, and then run it.&nbsp;</span><br>
<span style="font-size:small"><br>
&nbsp; <strong>net stop osearch15</strong></span><br>
<span style="font-size:small"><br>
&bull; Type the following command, and then run it.&nbsp;</span><br>
<span style="font-size:small"><br>
&nbsp; <strong>net start osearch15</strong></span> </li><li><span style="font-size:small">On the Search Administration page, click <strong>
Content Sources</strong>, and then click <strong>New Content Source</strong>.</span>
</li><li><span style="font-size:small">Specify a name for the content source, and in <strong>
Content Source Type</strong>, click <strong>Custom Repository</strong>.</span> </li><li><span style="font-size:small">In <strong>Type of Repository</strong>, click <strong>
myfile</strong>.</span> </li><li><span style="font-size:small">In <strong>Start Addresses</strong>, type the following:</span><br>
<strong><span style="font-size:small">myhttp://code.msdn.microsoft.com/SharePoint-2013-MyFileConne-79d2ea26/file://FileServerName/FileShareName/</span>
</strong></li></ol>
<h1>Change log</h1>
<p><span style="font-size:small">First version:&nbsp;July 16, 2012</span></p>
<h1>Related content</h1>
<ul>
<li><span style="font-size:small"><a title="http://msdn.microsoft.com/library/38560a3b-69c6-4a56-97ca-3625bbd5755e.aspx" href="http://msdn.microsoft.com/library/38560a3b-69c6-4a56-97ca-3625bbd5755e.aspx">Search connector framework</a></span>
</li><li><span style="font-size:small"><a title="http://msdn.microsoft.com/library/3c67b1cf-5fca-4805-a1b5-c9ac1ff8aede.aspx" href="http://msdn.microsoft.com/library/3c67b1cf-5fca-4805-a1b5-c9ac1ff8aede.aspx">Enhancing the BDC Model File for Search</a></span>
</li></ul>

</div>


    </div>
</body>
</html>
